﻿@model IPagination
@{
    string url = ViewContext.Controller.ControllerContext.HttpContext.Request.Url.PathAndQuery;
    url = Url.SetQueryPath(url, "page");
}
<ul class="pagination" style="margin-top: 0px; margin-bottom: 0px;">
    @if (Model.CurrentPage == 1)
    {
        <li class="disabled"><a>&laquo;</a></li>
    }
    else
    {
        <li><a data-nav="true" href="@Html.Raw(url)1">&laquo;</a></li>
    }
    @{int count = 0;
    while (count < 5 && Model.CurrentPage - 2 + count <= Model.TotalPage)
    {
        if (Model.CurrentPage - 2 + count < 1)
        {
            count++;
            continue;
        }
        if (count == 2)
        {
            <li class="active"><a>@Html.Raw(Model.CurrentPage - 2 + count)</a></li>
        }
        else
        {
            <li><a data-nav="true" href="@Html.Raw(url + (Model.CurrentPage - 2 + count))">@(Model.CurrentPage - 2 + count)</a></li>
        }
        count++;
    }
    if (Model.CurrentPage == Model.TotalPage)
    {
        <li class="disabled"><a>&raquo;</a></li>
    }
    else
    {
        <li><a data-nav="true" href="@Html.Raw( url + Model.TotalPage)">&raquo;</a></li>
    }
    }
</ul>